Summary for India

Row

confirmed

2,589,952

active

677,714 (26.2%)

death

49,980 (1.9%)

Row

Daily cumulative cases by type (India only)

Row ———————————————————————–

Daily cumulative cases by type Log10 Scale (India only)

Comparison

Column

** Daily Growth Rate of Total Cases from March (India Only)**

** Daily Growth Rate of Total Cases from March (US Only)**

Column

Country Wise Daily new Cases Smoothened over last 4 days average

Daily Confirmed Cases raw

Country Wise

Cases distribution by Country

Summary for US

Row

confirmed

5,361,165

active

3,373,157 (62.9%)

death

169,481 (3.2%)

Row

Daily cumulative cases by type (United States only)

Row ———————————————————————–

Daily cumulative cases by type Log10 Scale (United States only)

India and US Daily stats

Column

Cases for India

Cases for India smoothened

Column

Cases for US

Cases for US smoothened

India and US Daily Death Rates

Row

Cases for India

Row

Cases for US

---
title: "Coronavirus India & US Dashboard"
author: "by Mithun Ghosh"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    # social: ["facebook", "twitter", "linkedin"]
    source_code: embed
    vertical_layout: fill
---

```{r setup, include=FALSE}
#------------------ Packages ------------------
library(flexdashboard)
# install.packages("devtools")
# devtools::install_github("RamiKrispin/coronavirus", force = TRUE)
#library(coronavirus)
#data(coronavirus)
#update_datasets()
# View(coronavirus)
# max(coronavirus$date)
coronavirus <- read.csv(file="https://raw.githubusercontent.com/RamiKrispin/coronavirus/master/csv/coronavirus.csv",header=TRUE,sep=",")

`%>%` <- magrittr::`%>%`
#------------------ Parameters ------------------
# Set colors
# https://www.w3.org/TR/css-color-3/#svg-color
confirmed_color <- "purple"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
#------------------ Data ------------------
df <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "India") %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death) -ifelse(is.na(recovered), 0, recovered) ) %>%
  dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", as.character(country))) %>%
  dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>%
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))

df_daily <- coronavirus %>%
  dplyr::filter(country == "India") %>%
  dplyr::group_by(date, type) %>%
  dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  dplyr::arrange(date) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(active = confirmed - death -recovered) %>%
  dplyr::mutate(
    confirmed_cum = cumsum(confirmed),
    death_cum = cumsum(death),
    recovered_cum = cumsum(recovered),
    active_cum = cumsum(active)
  )

df_daily_us <- coronavirus %>%
  dplyr::filter(country == "US") %>%
  dplyr::group_by(date, type) %>%
  dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  dplyr::arrange(date) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(active = confirmed - death -recovered) %>%
  dplyr::mutate(
    confirmed_cum = cumsum(confirmed),
    death_cum = cumsum(death),
    recovered_cum = cumsum(recovered),
    active_cum = cumsum(active)
  )

df1 <- coronavirus %>% dplyr::filter(date == max(as.character(date)))
```

Summary for India
=======================================================================

Row {data-width=400}
-----------------------------------------------------------------------

### confirmed {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```


### active {.value-box}
```{r}
 valueBox( 
   value = paste(format(sum(df$unrecovered, na.rm = TRUE), big.mark = ","), " (",
     round(100 * sum(df$unrecovered, na.rm = TRUE) / sum(df$confirmed), 1),
     "%)",
     sep = "" 
   ),
   caption = "Active cases (% of total cases)", icon = "fas fa-ambulance",
   color = active_color
 ) 
``` 

### death {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df$death, na.rm = TRUE), big.mark = ","), " (",
    round(100 * sum(df$death, na.rm = TRUE) / sum(df$confirmed), 1),
    "%)",
    sep = ""
  ),
  caption = "Death cases (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```


Row
-----------------------------------------------------------------------

### **Daily cumulative cases by type** (India only)

```{r}
df_daily <- df_daily %>% dplyr::filter(as.character(date) > "2020-01-31") 
plotly::plot_ly(data = df_daily) %>%
  plotly::add_trace(
    x = ~date,
    # y = ~active_cum,
    y = ~confirmed_cum,
    type = "scatter",
    mode = "lines+markers",
    # name = "Active",
    name = "Confirmed",
    line = list(color = confirmed_color),
    marker = list(color = confirmed_color)
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~ confirmed_cum - recovered_cum - death_cum,
    type = "scatter",
    mode = "lines+markers",
    name = "Active Cases",
    line = list(color = active_color),
    marker = list(color = active_color)
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~ recovered_cum,
    type = "scatter",
    mode = "lines+markers",
    name = "Recovered",
    line = list(color = recovered_color),
    marker = list(color = recovered_color)
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~death_cum,
    type = "scatter",
    mode = "lines+markers",
    name = "Death",
    line = list(color = death_color),
    marker = list(color = death_color)
  ) %>%
  plotly::add_annotations(
    x = as.Date("2020-01-31"),
    y = 1,
    text = paste("First case"),
    xref = "x",
    yref = "y",
    arrowhead = 5,
    arrowhead = 3,
    arrowsize = 1,
    showarrow = TRUE,
    ax = -10,
    ay = -90
  ) %>%
  plotly::add_annotations(
    x = as.Date("2020-03-12"),
    y = 3,
    text = paste("First death"),
    xref = "x",
    yref = "y",
    arrowhead = 5,
    arrowhead = 3,
    arrowsize = 1,
    showarrow = TRUE,
    ax = -90,
    ay = -90
  ) %>%
  plotly::add_annotations(
    x = as.Date("2020-03-22"),
    y = 14,
    text = paste(
      "New containment",
      "
", "measures" ), xref = "x", yref = "y", arrowhead = 5, arrowhead = 3, arrowsize = 1, showarrow = TRUE, ax = -10, ay = -90 ) %>% plotly::layout( title = "", yaxis = list(title = "Cumulative number of cases"), xaxis = list(title = "Date"), legend = list(x = 0.1, y = 0.9), hovermode = "compare" ) ``` Row ----------------------------------------------------------------------- ### **Daily cumulative cases by type Log10 Scale** (India only) ```{r} plotly::plot_ly(data = df_daily) %>% plotly::add_trace( x = ~date, # y = ~active_cum, y = ~log10(confirmed_cum), type = "scatter", mode = "lines+markers", # name = "Active", name = "Confirmed", line = list(color = confirmed_color), marker = list(color = confirmed_color) ) %>% plotly::add_trace( x = ~date, y = ~ log10(confirmed_cum - recovered_cum - death_cum), type = "scatter", mode = "lines+markers", name = "Active Cases", line = list(color = active_color), marker = list(color = active_color) ) %>% plotly::add_trace( x = ~date, y = ~ log10(recovered_cum), type = "scatter", mode = "lines+markers", name = "Recovered", line = list(color = recovered_color), marker = list(color = recovered_color) ) %>% plotly::add_trace( x = ~date, y = ~log10(death_cum), type = "scatter", mode = "lines+markers", name = "Death", line = list(color = death_color), marker = list(color = death_color) ) %>% plotly::layout( title = "", yaxis = list(title = "Cumulative number of cases"), xaxis = list(title = "Date"), legend = list(x = 0.1, y = 0.9), hovermode = "compare" ) ``` Comparison ========================================================================================= Column ------------------------------------------------------------------------------- ### ** Daily Growth Rate of Total Cases from March (India Only)** ```{r} df_april <- df_daily %>% dplyr::filter(as.character(date) > "2020-03-06") %>% dplyr::mutate(total_case_growth = confirmed_cum / dplyr::lag(confirmed_cum,k=1)) %>% dplyr::mutate(active_case_growth = active_cum / dplyr::lag(active_cum,k=1)) %>% dplyr::mutate(death_case_growth = death_cum / dplyr::lag(death_cum,k=1)) plotly::plot_ly(data = df_april) %>% plotly::add_trace( x = ~date, y = ~ total_case_growth - 1, type = "scatter", mode = "lines+markers", name = " Daily Growth Rate of Total Cases", line = list(color = active_color), marker = list(color = active_color) ) %>% plotly::add_trace( x = ~date, y = ~ active_case_growth - 1, type = "scatter", mode = "lines+markers", name = " Daily Growth Rate of Active Cases", line = list(color = recovered_color), marker = list(color = recovered_color) ) %>% # plotly::add_trace( # x = ~date, # y = ~ death_case_growth - 1, # type = "scatter", # mode = "lines+markers", # name = " Daily Growth Rate of Death Cases", # line = list(color = death_color), # marker = list(color = death_color) # ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily Growth Rate"), xaxis = list(title = "Date") ) ``` ### ** Daily Growth Rate of Total Cases from March (US Only)** ```{r} df_april <- df_daily_us %>% dplyr::filter(as.character(date) > "2020-03-06") %>% dplyr::mutate(total_case_growth = confirmed_cum / dplyr::lag(confirmed_cum,k=1)) %>% dplyr::mutate(active_case_growth = active_cum / dplyr::lag(active_cum,k=1)) %>% dplyr::mutate(death_case_growth = death_cum / dplyr::lag(death_cum,k=1)) plotly::plot_ly(data = df_april) %>% plotly::add_trace( x = ~date, y = ~ total_case_growth - 1, type = "scatter", mode = "lines+markers", name = " Daily Growth Rate of Total Cases", line = list(color = active_color), marker = list(color = active_color) ) %>% plotly::add_trace( x = ~date, y = ~ active_case_growth - 1, type = "scatter", mode = "lines+markers", name = " Daily Growth Rate of Active Cases", line = list(color = recovered_color), marker = list(color = recovered_color) ) %>% # plotly::add_trace( # x = ~date, # y = ~ death_case_growth - 1, # type = "scatter", # mode = "lines+markers", # name = " Daily Growth Rate of Death Cases", # line = list(color = death_color), # marker = list(color = death_color) # ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily Growth Rate"), xaxis = list(title = "Date") ) ``` Column ------------------------------------------------------------------------------- ### **Country Wise Daily new Cases Smoothened over last 4 days average** ```{r} daily_confirmed <- coronavirus %>% dplyr::filter(type == "confirmed") %>% dplyr::filter(as.Date(date) >= "2020-03-06") %>% dplyr::mutate(country = country) %>% dplyr::group_by(date, country) %>% dplyr::summarise(total = sum(cases)) %>% dplyr::ungroup() %>% tidyr::pivot_wider(names_from = country, values_from = total) #---------------------------------------- # Plotting the data col_smoother <- function(col_val){ abs_col_val<-abs(col_val) return((abs_col_val+dplyr::lag(x = abs_col_val,default = 0)+dplyr::lag(x = abs_col_val,n = 2,default = 0)+dplyr::lag(x = abs_col_val,n = 3,default = 0))/4) } daily_confirmed %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~col_smoother(India), type = "scatter", mode = "lines", name = "India" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(France), type = "scatter", mode = "lines", name = "France" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Russia), type = "scatter", mode = "lines", name = "Russia" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Iran), type = "scatter", mode = "lines", name = "Iran" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(US), type = "scatter", mode = "lines", name = "US" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Brazil), type = "scatter", mode = "lines", name = "Brazil" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Bangladesh), type = "scatter", mode = "lines", name = "Bangladesh" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Germany), type = "scatter", mode = "lines", name = "Germany" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Italy), type = "scatter", mode = "lines", name = "Italy" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Spain), type = "scatter", mode = "lines", name = "Spain" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(Pakistan), type = "scatter", mode = "lines", name = "Pakistan" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Number of new confirmed cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` ### **Daily Confirmed Cases raw** ```{r} #---------------------------------------- # Plotting the data daily_confirmed %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~abs(India), type = "scatter", mode = "lines+markers", name = "India" ) %>% plotly::add_trace( x = ~date, y = ~abs(France), type = "scatter", mode = "lines+markers", name = "France" ) %>% plotly::add_trace( x = ~date, y = ~abs(Russia), type = "scatter", mode = "lines+markers", name = "Russia" ) %>% plotly::add_trace( x = ~date, y = ~abs(Iran), type = "scatter", mode = "lines+markers", name = "Iran" ) %>% plotly::add_trace( x = ~date, y = ~abs(US), type = "scatter", mode = "lines+markers", name = "US" ) %>% plotly::add_trace( x = ~date, y = ~abs(Brazil), type = "scatter", mode = "lines+markers", name = "Brazil" ) %>% plotly::add_trace( x = ~date, y = ~abs(Bangladesh), type = "scatter", mode = "lines+markers", name = "Bangladesh" ) %>% plotly::add_trace( x = ~date, y = ~abs(Germany), type = "scatter", mode = "lines+markers", name = "Germany" ) %>% plotly::add_trace( x = ~date, y = ~abs(Italy), type = "scatter", mode = "lines+markers", name = "Italy" ) %>% plotly::add_trace( x = ~date, y = ~abs(Spain), type = "scatter", mode = "lines+markers", name = "Spain" ) %>% plotly::add_trace( x = ~date, y = ~abs(Pakistan), type = "scatter", mode = "lines+markers", name = "Pakistan" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Number of new confirmed cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` Country Wise ======================================================================================== ### **Cases distribution by Country** ```{r daily_summary} df_EU <- coronavirus %>% # dplyr::filter(date == max(date)) %>% dplyr::filter(country %in% c("US","Spain","Italy","France","Germany","China","Iran","United Kingdom","Bangladesh","Turkey","Pakistan","Canada","Brazil","Netherlands","Russia", "Switzerland","Portugal","Austria","Sweden","Finland","India")) %>% dplyr::group_by(country, type) %>% dplyr::summarise(total = sum(cases)) %>% tidyr::pivot_wider( names_from = type, values_from = total ) %>% # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>% dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>% dplyr::arrange(confirmed) %>% dplyr::ungroup() %>% dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", as.character(country))) %>% dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>% dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>% dplyr::mutate(country = trimws(country)) %>% dplyr::mutate(country = factor(country, levels = country)) plotly::plot_ly( data = df_EU, x = ~country, # y = ~unrecovered, y = ~ confirmed - recovered -death, # text = ~ confirmed, # textposition = 'auto', type = "bar", name = "Active", marker = list(color = active_color) ) %>% plotly::add_trace( y = ~death, # text = ~ death, # textposition = 'auto', name = "Death", marker = list(color = death_color) ) %>% plotly::add_trace( y = ~recovered, name = "Recovered", marker = list(color = recovered_color) )%>% plotly::layout( barmode = "stack", yaxis = list(title = "Total cases"), xaxis = list(title = ""), hovermode = "compare", legend = list(x = 0.1, y = 0.9), margin = list( # l = 60, # r = 40, b = 10, t = 10, pad = 2 ) ) ``` Summary for US ======================================================================= ```{r} df_US <- coronavirus %>% # dplyr::filter(date == max(date)) %>% dplyr::filter(country == "US") %>% dplyr::group_by(country, type) %>% dplyr::summarise(total = sum(cases)) %>% tidyr::pivot_wider( names_from = type, values_from = total ) %>% # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>% dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death) - ifelse(is.na(recovered), 0, recovered)) %>% dplyr::arrange(-confirmed) %>% dplyr::ungroup() %>% dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", as.character(country))) %>% dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>% dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>% dplyr::mutate(country = trimws(country)) %>% dplyr::mutate(country = factor(country, levels = country)) df_daily_US <- coronavirus %>% dplyr::filter(country == "US") %>% dplyr::group_by(date, type) %>% dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>% tidyr::pivot_wider( names_from = type, values_from = total ) %>% dplyr::arrange(date) %>% dplyr::ungroup() %>% dplyr::mutate(active = confirmed - death -recovered) %>% dplyr::mutate( confirmed_cum = cumsum(confirmed), death_cum = cumsum(death), recovered_cum = cumsum(recovered), active_cum = cumsum(active) ) ``` Row {data-width=400} ----------------------------------------------------------------------- ### confirmed {.value-box} ```{r} valueBox( value = paste(format(sum(df_US$confirmed), big.mark = ","), "", sep = " "), caption = "Total confirmed cases", icon = "fas fa-user-md", color = confirmed_color ) ``` ### active {.value-box} ```{r} valueBox( value = paste(format(sum(df_US$unrecovered, na.rm = TRUE), big.mark = ","), " (", round(100 * sum(df_US$unrecovered, na.rm = TRUE) / sum(df_US$confirmed), 1), "%)", sep = "" ), caption = "Active cases (% of total cases)", icon = "fas fa-ambulance", color = active_color ) ``` ### death {.value-box} ```{r} valueBox( value = paste(format(sum(df_US$death, na.rm = TRUE), big.mark = ","), " (", round(100 * sum(df_US$death, na.rm = TRUE) / sum(df_US$confirmed), 1), "%)", sep = "" ), caption = "Death cases (death rate)", icon = "fas fa-heart-broken", color = death_color ) ``` Row ----------------------------------------------------------------------- ### **Daily cumulative cases by type** (United States only) ```{r} plotly::plot_ly(data = df_daily_US) %>% plotly::add_trace( x = ~date, # y = ~active_cum, y = ~confirmed_cum, type = "scatter", mode = "lines+markers", # name = "Active", name = "Confirmed", line = list(color = confirmed_color), marker = list(color = confirmed_color) ) %>% plotly::add_trace( x = ~date, y = ~ confirmed_cum - recovered_cum - death_cum, type = "scatter", mode = "lines+markers", name = "Active Cases", line = list(color = active_color), marker = list(color = active_color) ) %>% plotly::add_trace( x = ~date, y = ~ recovered_cum, type = "scatter", mode = "lines+markers", name = "Recovered", line = list(color = recovered_color), marker = list(color = recovered_color) ) %>% plotly::add_trace( x = ~date, y = ~death_cum, type = "scatter", mode = "lines+markers", name = "Death", line = list(color = death_color), marker = list(color = death_color) ) %>% plotly::add_annotations( x = as.Date("2020-01-22"), y = 1, text = paste("First case"), xref = "x", yref = "y", arrowhead = 5, arrowhead = 3, arrowsize = 1, showarrow = TRUE, ax = -10, ay = -90 ) %>% plotly::add_annotations( x = as.Date("2020-02-29"), y = 3, text = paste("First death"), xref = "x", yref = "y", arrowhead = 5, arrowhead = 3, arrowsize = 1, showarrow = TRUE, ax = -90, ay = -90 ) %>% plotly::layout( title = "", yaxis = list(title = "Cumulative number of cases"), xaxis = list(title = "Date"), legend = list(x = 0.1, y = 0.9), hovermode = "compare" ) ``` Row ----------------------------------------------------------------------- ### **Daily cumulative cases by type Log10 Scale** (United States only) ```{r} plotly::plot_ly(data = df_daily_US) %>% plotly::add_trace( x = ~date, # y = ~active_cum, y = ~log10(confirmed_cum), type = "scatter", mode = "lines+markers", # name = "Active", name = "Confirmed", line = list(color = confirmed_color), marker = list(color = confirmed_color) ) %>% plotly::add_trace( x = ~date, y = ~ log10(confirmed_cum - recovered_cum - death_cum), type = "scatter", mode = "lines+markers", name = "Active Cases", line = list(color = active_color), marker = list(color = active_color) ) %>% plotly::add_trace( x = ~date, y = ~ log10(recovered_cum), type = "scatter", mode = "lines+markers", name = "Recovered", line = list(color = recovered_color), marker = list(color = recovered_color) ) %>% plotly::add_trace( x = ~date, y = ~log10(death_cum), type = "scatter", mode = "lines+markers", name = "Death", line = list(color = death_color), marker = list(color = death_color) ) %>% plotly::layout( title = "", yaxis = list(title = "Cumulative number of cases"), xaxis = list(title = "Date"), legend = list(x = 0.1, y = 0.9), hovermode = "compare" ) ``` India and US Daily stats =============================================================================== Column ------------------------------------------------------------------------------- ### **Cases for India** ```{r} #---------------------------------------- # Plotting the data df_daily %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% # plotly::add_trace( # x = ~date, # y = ~confirmed, # type = "scatter", # mode = "lines+markers", # name = "Confirmed" # ) %>% plotly::add_trace( x = ~date, y = ~death, type = "scatter", mode = "lines+markers", name = "Death" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(death), type = "scatter", mode = "lines", name = "Death Rate smoothened" ) %>% # plotly::add_trace( # x = ~date, # y = ~active, # type = "scatter", # mode = "lines+markers", # name = "Confirmed-Death-Recovered" # ) %>% # plotly::add_trace( # x = ~date, # y = ~recovered, # type = "scatter", # mode = "lines+markers", # name = "Recovered" # ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily new Death cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` ### **Cases for India smoothened** ```{r} #---------------------------------------- # Plotting the data df_daily %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~col_smoother(confirmed), type = "scatter", mode = "lines+markers", name = "Confirmed" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(death), type = "scatter", mode = "lines+markers", name = "Death" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(active), type = "scatter", mode = "lines+markers", name = "Confirmed-Death-Recovered" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(recovered), type = "scatter", mode = "lines+markers", name = "Recovered" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Number of Daily new cases smoothened over last 4 days"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` Column ---------------------------------------------------------------------------------- ### **Cases for US** ```{r} #---------------------------------------- # Plotting the data df_daily_us %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% # plotly::add_trace( # x = ~date, # y = ~confirmed, # type = "scatter", # mode = "lines+markers", # name = "Confirmed" # ) %>% plotly::add_trace( x = ~date, y = ~death, type = "scatter", mode = "lines+markers", name = "Death" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(death), type = "scatter", mode = "lines", name = "Death Rate smoothened" ) %>% # plotly::add_trace( # x = ~date, # y = ~active, # type = "scatter", # mode = "lines+markers", # name = "Confirmed-death-Recovered" # ) %>% # plotly::add_trace( # x = ~date, # y = ~recovered, # type = "scatter", # mode = "lines+markers", # name = "Recovered" # ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily new Death cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` ### **Cases for US smoothened** ```{r} #---------------------------------------- # Plotting the data US df_daily_us %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~col_smoother(confirmed), type = "scatter", mode = "lines+markers", name = "Confirmed" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(death), type = "scatter", mode = "lines+markers", name = "Death" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(active), type = "scatter", mode = "lines+markers", name = "Confirmed-Death-Recovered" ) %>% plotly::add_trace( x = ~date, y = ~col_smoother(recovered), type = "scatter", mode = "lines+markers", name = "Recovered" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Number of Daily new cases smoothened over last 4 days"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` India and US Daily Death Rates =============================================================================== Row ------------------------------------------------------------------------------- ### **Cases for India** ```{r} #---------------------------------------- # Plotting the data df_daily %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~ col_smoother(death) / col_smoother(confirmed), type = "scatter", mode = "lines", name = "Death Rate (Death/Confirmed for that day) smoothened" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily new Death cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ``` Row ------------------------------------------------------------------------------- ### **Cases for US** ```{r} #---------------------------------------- # Plotting the data df_daily_us %>% dplyr::filter(as.character(date) > "2020-03-31") %>% plotly::plot_ly() %>% plotly::add_trace( x = ~date, y = ~ col_smoother(death) / col_smoother(confirmed), type = "scatter", mode = "lines", name = "Death Rate (Death/Confirmed for that day) smoothened" ) %>% plotly::layout( title = "", legend = list(x = 0.1, y = 0.9), yaxis = list(title = "Daily new Death cases"), xaxis = list(title = "Date"), hovermode = "compare", margin = list( b = 10, t = 10, pad = 2 ) ) ```